package com.lw.staservice.schedule;

import com.lw.staservice.service.StaService;
import com.lw.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduleTask {
    @Autowired
    private StaService staService;

    //在每天凌晨一点，把前一天的数据进行统计添加
    @Scheduled(cron = "0 0 1 * * ?") //6位 第七位不写
    public void task(){
        //通过工具类得到前天的日期
        staService.registerCount( DateUtil.formatDate(DateUtil.addDays(new Date(), -1)) );
    }
}
